package com.jgp.security.controller;

import com.jgp.common.pojo.TreeBean;
import com.jgp.security.pojo.InstitutionUserRequestParam;
import com.jgp.security.service.SecInstitutionUserService;
import com.jgp.sys.controller.JGPBackController;
import com.jgp.sys.ui.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019-11-04
 */
@RestController
@RequestMapping("/security/institution-user-api-ctl")
public class InstitutionUserApiController extends JGPBackController {
    
    @Autowired
    private SecInstitutionUserService service;
    
    
    @RequestMapping("modify-user-institution")
    public Result modifyUserInstitution(@RequestBody InstitutionUserRequestParam param){
        service.modifyUserInstitution(param.getUserId(),param.getInstitutionIds());
        return ajaxRe(true);
    }
    
    @RequestMapping("query-institution-ids")
    public Result queryInstitutionIds(String userId){
        List<Long> institutions = service.queryInstitutionIds(userId);
        return ajaxReData("institutions",institutions);
    }
    
    
    @RequestMapping("query-private-institution-tree")
    public List<TreeBean> queryPrivateInstitutionTree(String userId){
        return service.queryPrivateInstitutionTree(userId);
    }
    
}
